from django.db import models
from dingxiang_doctor.utils.basemodels import BaseModel

# Create your models here.
class FirstLevel(BaseModel):
    category_choices = {
        (0, "大众健康"),
        (1, "生活手册")
    }

    category = models.SmallIntegerField(choices=category_choices, null=True, verbose_name="分类")
    class Meta:
        db_table = 'first_level'
        verbose_name_plural = "一级分类"

class SecondLevel(BaseModel):
    first_level = models.ForeignKey(FirstLevel, on_delete=models.CASCADE, verbose_name="一级分类")
    class Meta:
        db_table = 'second_level'
        verbose_name_plural = "二级分类"

class Article(BaseModel):
    title = models.CharField(max_length=100, null=True, verbose_name="标题")
    content = models.TextField(null=True, verbose_name="内容")
    author = models.CharField(max_length=200, verbose_name="作者")
    second_level = models.ForeignKey(SecondLevel, on_delete=models.CASCADE, verbose_name="二级分类")
    class Meta:
        db_table = 'article'
        verbose_name_plural = "文章"

